package com.fatcat.easybuy.config;

import com.fatcat.easybuy.interceptor.UserCheckInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 郝秦毅
 * @since 2025/9/12 15:57
 */
@Configuration
public class UserCheckInterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private UserCheckInterceptor userCheckInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(userCheckInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/user/login",
                        "/user/register",
                        "/news/getAllNews", "/news/getNewsById/{id}",
                        "/email/**", "/user/checkLoginName", "/product/searchProduct", "/product/getProductById/{id}", "/category/**", "/swagger-ui.html", "/swagger-ui/**", "/swagger-resources/**", "/v2/api-docs", "/webjars/**", "/alipay/return_url", "/alipay/notify_url", "/alipay/AlipayCallbackView", "/VXpay/wxNotify");
    }
}
